package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.Recruit;
import com.xmy.cultivate.entity.RecruitList;
import com.xmy.cultivate.mapper.RecruitMapper;
import com.xmy.cultivate.respons.RecruitAnalysisRs;
import com.xmy.cultivate.service.IRecruitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 招聘信息 服务实现类
 * </p>
 *
 * @author hpiggy
 * @since 2024-11-27
 */
@Service
public class RecruitServiceImpl extends ServiceImpl<RecruitMapper, Recruit> implements IRecruitService {
    @Autowired
    private RecruitMapper recruitMapper;

    public IPage<Recruit> findAll(IPage<?> page, @Param(Constants.WRAPPER) Wrapper wrapper){
        IPage<Recruit> mapList = recruitMapper.findAll(page,wrapper);
        return mapList;
    }

    public List<RecruitList> countList(@Param("startDate") String startDate,@Param("endDate") String endDate){
        List<RecruitList> recruitLists = recruitMapper.countList(startDate,endDate);
        return recruitLists;
    }

   public IPage<Recruit> dataCountTryJobDetail(IPage<?> page,  String startDate, String endDate, String inviterId, Integer recruitStatus){
        return recruitMapper.dataCountTryJobDetail(page,startDate,endDate,inviterId,recruitStatus);

   }


    public IPage<Recruit> oneDayCountDetail(IPage<?> page, String inviterId, Integer recruitStatus){
        return recruitMapper.oneDayCountDetail(page,inviterId,recruitStatus);

    }

    public IPage<Recruit> oneDayCountTryJobDetail(IPage<?> page, String inviterId, Integer recruitStatus){
        return recruitMapper.oneDayCountTryJobDetail(page,inviterId,recruitStatus);

    }

   public boolean updateRecruit(String id, Integer status, String inviteDateTime, Integer resultStatus, String turnDownContent, Integer isArrive, Integer interviewStatus){
        Integer update = recruitMapper.updateRecruit(id,status,inviteDateTime,resultStatus,turnDownContent,isArrive,interviewStatus);
        if (update > 0){
            return true;
        }
        return false;
   }


/*    public List<RecruitList> getRecruitCount( String startDate, String endDate, String recruitStatus){
        List<RecruitList> recruitLists = recruitMapper.getRecruitCount(startDate,endDate,recruitStatus);
        return recruitLists;
    }*/

    public List<RecruitList> getRecruitCount( String recruitStatus){
        List<RecruitList> recruitLists = recruitMapper.getRecruitCount(recruitStatus);
        return recruitLists;
    }

    public List<RecruitList> getTryJobCount( String recruitStatus){
        return recruitMapper.getTryJobCount(recruitStatus);
    }

    public List<RecruitList> getRecruitCountByWeek( String recruitStatus){
        return recruitMapper.getRecruitCountByWeek(recruitStatus);
    }

    public List<RecruitList> getTryJobCountByWeek( String recruitStatus){
        return recruitMapper.getTryJobCountByWeek(recruitStatus);
    }

    public IPage<Recruit> oneWeekCountDetail(IPage<?> page, String inviterId, Integer recruitStatus){
        return recruitMapper.oneWeekCountDetail(page,inviterId,recruitStatus);
    }

    public IPage<Recruit> oneWeekTryJobCountDetail(IPage<?> page, String inviterId, Integer recruitStatus){
        return recruitMapper.oneWeekTryJobCountDetail(page,inviterId,recruitStatus);
    }

    public List<RecruitList> resumeData(String startDate, String endDate, String departmentId, String stationsId, String labourId, String type, String yearPart, String quarterNum, String dateType, String theirType, String subjectsId) {
        return recruitMapper.resumeData(startDate, endDate, departmentId, stationsId, labourId, type, yearPart, quarterNum, dateType, theirType, subjectsId);
    }

    public IPage<Recruit> resumeDataDetails(IPage<?> page, String startDate, String endDate, String departmentId, String stationsId, String labourId, String type, String inviterId, String yearPart, String quarterNum, String dateType, String recruitStatus, String theirType, String subjectsId) {
        return recruitMapper.resumeDataDetails(page, startDate, endDate, departmentId, stationsId, labourId, type, inviterId, yearPart, quarterNum, dateType, recruitStatus, theirType, subjectsId);
    }

    @Override
    public List<RecruitAnalysisRs> getRecruitAnalysisList(String yearPart, String quarterNum, String startDate, String endDate, String stationsId, String departmentId, String subjectsId, String labourId, String type, String theirType) {
        return recruitMapper.getRecruitAnalysisList(yearPart, quarterNum, startDate, endDate, stationsId, departmentId, subjectsId, labourId, type, theirType);
    }

    @Override
    public IPage<RecruitAnalysisRs> getRecruitAnalysisDetails(IPage<RecruitAnalysisRs> page, String yearPart, String quarterNum, String startDate, String endDate, String stationsId, String departmentId, String subjectsId, String labourId, String gradeDetailsId, String type, String theirType) {
        return recruitMapper.getRecruitAnalysisDetails(page, yearPart, quarterNum, startDate, endDate, stationsId, departmentId, subjectsId, labourId, gradeDetailsId, type, theirType);
    }

    @Override
    public List<RecruitAnalysisRs> getTryJobAnalysisList(String yearPart, String quarterNum, String startDate, String endDate, String stationsId, String departmentId, String subjectsId, String labourId, String type, String theirType) {
        return recruitMapper.getTryJobAnalysisList(yearPart, quarterNum, startDate, endDate, stationsId, departmentId, subjectsId, labourId, type, theirType);
    }

    @Override
    public IPage<RecruitAnalysisRs> getTryJobAnalysisDetails(IPage<RecruitAnalysisRs> page, String yearPart, String quarterNum, String startDate, String endDate, String stationsId, String departmentId, String subjectsId, String labourId, String gradeDetailsId, String type, String theirType) {
        return recruitMapper.getTryJobAnalysisDetails(page, yearPart, quarterNum, startDate, endDate, stationsId, departmentId, subjectsId, labourId, gradeDetailsId, type, theirType);
    }

    @Override
    public List<RecruitAnalysisRs> getTrialFormAnalysisList(String yearPart, String quarterNum, String startDate, String endDate, String stationsId, String departmentId, String subjectsId, String labourId, String type, String theirType) {
        return recruitMapper.getTrialFormAnalysisList(yearPart, quarterNum, startDate, endDate, stationsId, departmentId, subjectsId, labourId, type, theirType);
    }

    @Override
    public IPage<RecruitAnalysisRs> getTrialFormAnalysisDetails(IPage<RecruitAnalysisRs> page, String yearPart, String quarterNum, String startDate, String endDate, String stationsId, String departmentId, String subjectsId, String labourId, String gradeDetailsId, String type, String theirType) {
        return recruitMapper.getTrialFormAnalysisDetails(page, yearPart, quarterNum, startDate, endDate, stationsId, departmentId, subjectsId, labourId, gradeDetailsId, type, theirType);
    }

    /**
     * 判断是校区招，还是部门招，1校区招，2部门招
     * @param recruitId
     * @return
     */
    @Override
    public Integer getPersonType(Long recruitId){
        Integer personType = recruitMapper.getPersonType(recruitId);
        if (personType == null) {
            personType = 0;
        }
        return personType;
    }
}
